<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">

	<ui:composition 
	  xmlns="http://www.w3.org/1999/xhtml"
      xmlns:h="http://java.sun.com/jsf/html"
      xmlns:f="http://java.sun.com/jsf/core"
      xmlns:ui="http://java.sun.com/jsf/facelets"
      xmlns:p="http://primefaces.org/ui"
      template="/view/templates/templateLayout.xhtml">
      
      <ui:define name="conteudo">  
      <link rel="stylesheet" type="text/css" href="./estilos.css"/>     	
  	
<h:form id="formConsultarVenda" prependId="false">  
	<p:panel id="panelConsultarVenda" style="margin-bottom:20px; "> 
	<f:facet name="header">
		<h:outputText value="Consultar Venda" styleClass="outputTextTitulo"/>
	</f:facet> 
 	<p:messages id="messagesConsultarVenda" autoUpdate="true" closable="true" />
 		<h:panelGrid id="pgData" columns="2" style="margin-top:20px;">
 			<h:outputLabel value="Data de Emissão" styleClass="outputLabel" />
 			<h:outputLabel value="Data de Entrega" styleClass="outputLabel" />
 			<p:inputMask mask="99/99/9999" value="#{vendaBean.venda.dtEmissao}" styleClass="inputData">
 				<f:convertDateTime dateStyle="medium"/>
 			</p:inputMask>
 			<p:inputMask mask="99/99/9999" value="#{vendaBean.venda.dtEntrega}" styleClass="inputData">
 				<f:convertDateTime dateStyle="medium"/>
 			</p:inputMask>
 		</h:panelGrid>
 		<h:panelGrid id="pgNota" columns="2" >  
            <h:outputLabel value="Número da Nota" styleClass="outputLabel" />  
            <h:outputLabel value="Número de série" styleClass="outputLabel" /> 
            <p:inputText value="#{vendaBean.venda.numeroNota}" styleClass="inputData"/>  
            <p:inputText value="#{vendaBean.venda.numeroSerie}" styleClass="inputData" />
        </h:panelGrid>  
    	<h:panelGrid id="pgAluno" columns="2" >  
            <h:outputLabel value="Código" styleClass="outputLabel" /> 
            <h:outputLabel value="Aluno/Cliente" styleClass="outputLabel" /> 
            <p:inputText value="#{vendaBean.venda.aluno.idAluno}" styleClass="inputId" >
            	<p:ajax  listener="#{vendaBean.onChangeAluno}"  />
            </p:inputText>  
  			<p:inputText  value="#{vendaBean.venda.aluno.nome}" maxlength="40" styleClass="inputDescricao"/>
        </h:panelGrid>  
    </p:panel>  
    <p:commandButton value="Consultar" actionListener="#{vendaBean.findVenda}" update="dataTableVenda" style="margin-right:20px; margin-left:10px;" /> 
	<p:commandButton value="Novo" action="#{vendaBean.newVenda}" style="margin-right:20px;" /> 
	<p:commandButton value="Limpar"  actionListener="#{vendaBean.clean}" update="panelConsultarVenda, dataTableVenda" style="margin-right:20px;" />
    		
   		
    <p:dataTable id="dataTableVenda" var="Venda" value="#{vendaBean.dmVenda}"  
    			 rowKey="#{Venda.idVenda}"  selectionMode="single"
                 style="padding-top:20px; width:70%" paginator="true" rows="10"  
                 paginatorTemplate="{CurrentPageReport}  {FirstPageLink} {PreviousPageLink} {PageLinks} {NextPageLink} {LastPageLink} {RowsPerPageDropdown}"  
                 rowsPerPageTemplate="5,10,15">  
        <f:facet name="header">Vendas</f:facet>    
		<p:column sortBy="#{Venda.numeroNota}" style="width:12%; text-align:center">  
            <f:facet name="header">  
                <h:outputText value="Número da Nota" />  
            </f:facet>  
            <h:outputText value="#{Venda.numeroNota}" />  
        </p:column>  
        <p:column sortBy="#{Venda.numeroSerie}" style="width:12%; text-align:center">  
            <f:facet name="header">  
                <h:outputText value="Número de Série" />  
            </f:facet>  
            <h:outputText value="#{Venda.numeroSerie}" />  
        </p:column> 
  
        <p:column sortBy="#{Venda.aluno.nome}">  
            <f:facet name="header">  
                <h:outputText value="Cliente" />  
            </f:facet>  
            <h:outputText value="#{Venda.aluno.nome}" />  
        </p:column>  
        <p:column sortBy="#{Venda.dtEmissao}" style="width:12%; text-align:center">  
            <f:facet name="header">  
                <h:outputText value="Data de Emissão" />  
            </f:facet>  
            <h:outputText value="#{Venda.dtEmissao}" >
            	<f:convertDateTime dateStyle="medium"/>
            </h:outputText>  
        </p:column>
        <p:column sortBy="#{Venda.dtEntrega}" style="width:12%; text-align:center">  
            <f:facet name="header">  
                <h:outputText value="Data de Entrega" />  
            </f:facet>  
            <h:outputText value="#{Venda.dtEntrega}" >
            	<f:convertDateTime dateStyle="medium"/>
            </h:outputText>  
        </p:column>
         <p:column style="width:10%" sortBy="#{Venda.valorTotal}">  
            <f:facet name="header">  
                <h:outputText value="Total" />  
            </f:facet>  
            <h:outputText value="#{Venda.valorTotal}" >
            	<f:convertNumber type="currency" currencySymbol="R$ " maxFractionDigits="2" minFractionDigits="2"/>
            </h:outputText>  
        </p:column>
        <p:column sortBy="#{Venda.status}" style="width:10%; text-align:center">  
            <f:facet name="header">  
                <h:outputText value="Status" />  
            </f:facet>  
            <h:outputText value="#{Venda.status}" />  
        </p:column> 
        <p:column style="width:4%; text-align:center">  
        	<f:facet name="header">
        	 <h:outputText value="Editar" />
        	</f:facet>
         	<p:commandButton id="selectButtonEditar" action="#{vendaBean.editarVenda}" icon="ui-icon-pencil" title="Detail" />
        </p:column> 
    </p:dataTable>    
</h:form>  	
</ui:define>
</ui:composition>
